﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<SuperStarProject.Models.PhieuMuaHangModel>" %>
<script type="text/javascript" language="javascript">
    function GetMaDaiLy() {
        var maDaiLy = document.getElementsByName("DaiLyListBox")[0].value;
        document.getElementsByName("MaDaiLy")[0].value = maDaiLy;
    }
    function TinhTien() {
        var diemthuong = parseInt(document.getElementsByName("DiemThuong")[0].value); 
        var soluong = parseInt(document.getElementsByName("SoLuong")[0].value);
        var dongia = parseInt(document.getElementsByName("DonGia")[0].value);
        var tong = soluong * dongia;
        document.getElementsByName("TongTien")[0].value = tong;
        document.getElementsByName("SoLuongMua")[0].value = soluong;
        document.getElementsByName("TongDiemThuong")[0].value = soluong * diemthuong;    
    }
</script>






                <!----0------------------------------------->
                <div class="uc_form">
                <div class="uc_form_subtitle">Nhập yêu cầu mua hàng</div>    
                    <div class="uc_form_row">                  
                    <% Html.RenderAction("ShowAllDaiLy", "DaiLy");%>
                    </div>                    
                   <label class="uc_contact"><strong>Số lượng:</strong></label> 
                   <select class="uc_contact_input" name="SoLuong" id="Select1" onchange="TinhTien();">
                    <% for(int i =1; i <= Model.SoLuongMua ;i++)
                        {%>
                            <option value=<%=i%>><%=i%></option>
                    <% }%>
                    </select>
                    
 
                    <%using (Html.BeginForm("Create","PhieuMuaHang",FormMethod.Post)) {%>
                    <%--<%= Html.ValidationSummary(true) %>--%>
                    <div class="form_row">
                    <input type="submit" class="muahang" value="Mua ngay" />
                    </div>   
                </div>
                <!----0------------------------------------->
<%--                <fieldset>
                <legend>Nhập thông tin mua hàng</legend>
                   <% Html.RenderAction("ShowAllDaiLy", "DaiLy");%><br />
                   Số lượng : <select name="SoLuong" id="SoLuong" onchange="TinhTien();">
                    <% for(int i =1; i <= Model.SoLuongMua ;i++)
                        {%>
                            <option value=<%=i%>><%=i%></option>
                    <% }%>
                </select>
                </fieldset>--%>
                <!----0------------------------------------->
                <div class="uc_form">
                <div class="uc_form_subtitle">Chi tiết thanh toán, điểm thưởng</div>  
                    <%= Html.HiddenFor(model => model.MaPhieuMuaHang)%>
                    <%= Html.HiddenFor(model => model.MaKH)%>
                    <%= Html.HiddenFor(model => model.MaSP)%>
                    <%= Html.HiddenFor(model => model.MaDaiLy)%>

                    <%= Html.HiddenFor(model => model.NgayMua)%>
                    <%Model.SoLuongMua = 1; %>
                    <%= Html.HiddenFor(model => model.SoLuongMua)%>    
                    <div class="uc_form_row">
                    <label class="uc_contact"><strong>Đơn giá:</strong></label>
                    <%=Html.TextBox("DonGia", Model.TongTien.ToString(), new { @readonly = "readonly", @class = "uc_contact_input" })%>
                    </div>
                     
                    <div class="uc_form_row">  
                    <label class="uc_contact"><strong>Tổng tiền:</strong></label>
                    <%=Html.TextBox("TongTien", Model.TongTien.ToString(), new { @readonly = "readonly", @class = "uc_contact_input" })%>
                    </div> 
                    
                    <div class="uc_form_row"> 
                    <label class="uc_contact"><strong>Đ.thưởng:</strong></label>
                    <%=Html.TextBox("DiemThuong", Model.TongDiemThuong.ToString(), new { @readonly = "readonly", @class = "uc_contact_input" })%>
                    </div> 
                    
                    <div class="uc_form_row"> 
                    <label class="uc_contact"><strong>Tổng điểm:</strong></label>
                    <%=Html.TextBox("TongDiemThuong", Model.TongDiemThuong.ToString(), new { @readonly = "readonly", @class = "uc_contact_input" })%>
                    </div> 

                </div>
                <%} %>


